using Circus.CodeEditor;
using Circus.CodeEditor.Dialogs;
using Circus.CodeEditor.TextSource;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using System.Windows.Forms;
namespace Circus.CodeEditor
{
	public class SearchManager
	{
		private static SearchManager sharedSearch;
		private static SearchManager declarationSearch;
		private SearchSettings searchSettings = new SearchSettings();
		private bool firstSearch;
		private bool inCycledSearch;
		private bool isReplace;
		private SearchOptions searchOptions;
		private Regex searchExpression;
		private int updateCount;
		private string searchText = string.Empty;
		private string replaceText = string.Empty;
		protected IList<string> searchList = new List<string>();
		protected CodeEditor search;
		protected CodeEditor curSearch;
		protected CodeEditor cycledSearch;
		protected bool shared;
	    public static event CreateSearchManagerEvent CreateSharedSearch;
	    public event InitSearchEvent InitSearch;
	    public event GetSearchEvent GetSearch;
	    public event TextFoundEvent TextFound;
		public bool FirstSearch
		{
			get
			{
				return this.firstSearch;
			}
			set
			{
				this.firstSearch = value;
				if (value)
				{
					this.cycledSearch = null;
				}
			}
		}
		public string SearchText
		{
			get
			{
				return this.searchText;
			}
			set
			{
				this.searchText = value;
			}
		}
		public bool InCycledSearch
		{
			get
			{
				return this.inCycledSearch;
			}
			set
			{
				this.inCycledSearch = value;
			}
		}
		public CodeEditor Search
		{
			get
			{
				return this.search;
			}
		}
		public bool InIncrementalSearch
		{
			get
			{
				this.Init(ref this.search, SearchOptions.None);
				return this.search != null && this.search.InIncrementalSearch;
			}
		}
		public string IncrementalSearchString
		{
			get
			{
				this.Init(ref this.search, SearchOptions.None);
				return (this.search != null) ? this.search.IncrementalSearchString : string.Empty;
			}
		}
		public bool IsReplace
		{
			get
			{
				return this.isReplace;
			}
			set
			{
				this.isReplace = value;
			}
		}
		public Point SearchPos
		{
			get
			{
				this.Init(ref this.search, SearchOptions.None);
				return (this.search != null) ? this.search.SearchPos : Point.Empty;
			}
			set
			{
				CodeEditor search = this.Search;
				this.Init(ref search, SearchOptions.None);
				if (this.Search != null)
				{
					this.Search.SearchPos = value;
				}
			}
		}
		public SearchOptions SearchOptions
		{
			get
			{
				this.Init(ref this.search, SearchOptions.None);
				return (this.search != null) ? this.search.SearchOptions : SearchOptions.None;
			}
			set
			{
				this.Init(ref this.search, SearchOptions.None);
				if (this.search != null)
				{
					this.search.SearchOptions = value;
				}
			}
		}
		public int SearchLen
		{
			get
			{
				this.Init(ref this.search, SearchOptions.None);
				return (this.search != null) ? this.search.SearchLen : 0;
			}
		}
		public SearchDialog SearchDialog
		{
			get
			{
				this.Init(ref this.search, SearchOptions.None);
				return (this.search != null) ? this.search.SearchDialog : null;
			}
			set
			{
				this.Init(ref this.search, SearchOptions.None);
				if (this.search != null)
				{
					this.search.SearchDialog = value;
				}
			}
		}
        public DlgGoto GotoLineDialog
		{
			get
			{
				this.Init(ref this.search, SearchOptions.None);
				return (this.search != null) ? this.search.GotoLineDialog : null;
			}
			set
			{
				this.Init(ref this.search, SearchOptions.None);
				if (this.search != null)
				{
					this.search.GotoLineDialog = value;
				}
			}
		}
		public bool Shared
		{
			get
			{
				return this.shared;
			}
			set
			{
				this.shared = value;
			}
		}
		public static SearchManager SharedSearch
		{
			get
			{
				if (SearchManager.sharedSearch == null)
				{
					if (SearchManager.CreateSharedSearch != null)
					{
						CreateSearchManagerEventArgs createSearchManagerEventArgs = new CreateSearchManagerEventArgs();
						SearchManager.CreateSharedSearch(null, createSearchManagerEventArgs);
						SearchManager.sharedSearch = createSearchManagerEventArgs.SearchManager;
					}
					if (SearchManager.sharedSearch == null)
					{
						SearchManager.sharedSearch = new SearchManager();
					}
				}
				return SearchManager.sharedSearch;
			}
		}
		public static SearchManager DeclarationSearch
		{
			get
			{
				return SearchManager.declarationSearch;
			}
			set
			{
				SearchManager.declarationSearch = value;
			}
		}
		public SearchSettings SearchSettings
		{
			get
			{
				return this.searchSettings;
			}
			set
			{
				this.searchSettings = value;
			}
		}
		public virtual void InitSearchList(ref CodeEditor search, SearchOptions options)
		{
			if (this.firstSearch)
			{
				this.searchList.Clear();
				if (this.InitSearch != null)
				{
					InitSearchEventArgs initSearchEventArgs = new InitSearchEventArgs(search, this.searchList, options);
					this.InitSearch(this, initSearchEventArgs);
					search = initSearchEventArgs.Search;
				}
			}
		}
		protected CodeEditor GetSearchFromFile(string fileName)
		{
			CodeEditor result;
			if (this.GetSearch != null)
			{
				GetSearchEventArgs getSearchEventArgs = new GetSearchEventArgs(fileName);
				this.GetSearch(this, getSearchEventArgs);
				result = getSearchEventArgs.Search;
			}
			else
			{
				result = null;
			}
			return result;
		}
		protected bool NextSearch(SearchOptions searchOptions, ref string fileName, ref CodeEditor search)
		{
			bool result;
			if ((searchOptions & SearchOptions.AllDocuments) == SearchOptions.None && (searchOptions & SearchOptions.CurrentProject) == SearchOptions.None)
			{
				result = (search != null);
			}
			else
			{
				search = null;
				if (fileName == string.Empty)
				{
					if (this.searchList.Count > 0)
					{
						fileName = this.searchList[0];
						CodeEditor searchFromFile = this.GetSearchFromFile(fileName);
						if (searchFromFile != null)
						{
							search = searchFromFile;
						}
						result = true;
					}
					else
					{
						result = false;
					}
				}
				else
				{
					int num = this.searchList.IndexOf(fileName);
					if (num >= 0)
					{
						if (num < this.searchList.Count - 1)
						{
							fileName = this.searchList[num + 1];
						}
						else
						{
							fileName = this.searchList[0];
						}
						CodeEditor searchFromFile = this.GetSearchFromFile(fileName);
						if (searchFromFile != null)
						{
							search = searchFromFile;
						}
						result = true;
					}
					else
					{
						result = false;
					}
				}
			}
			return result;
		}
		protected virtual string GetSourceFileNameFromSearch(CodeEditor search)
		{
			return (search is CodeEditor) ? ((CodeEditor)search).Source.FileName : string.Empty;
		}
		protected virtual bool FindPrevious(string text)
		{
			bool result;
			if (this.CanFindPrevious())
			{
				if (text == null)
				{
					text = this.searchText;
				}
				if (this.searchExpression != null && (this.searchExpression.Options & RegexOptions.RightToLeft) == RegexOptions.None)
				{
					this.searchExpression = new Regex(this.searchExpression.ToString(), this.searchExpression.Options | RegexOptions.RightToLeft);
				}
				string sourceFileNameFromSearch = this.GetSourceFileNameFromSearch(this.search);
				string text2 = string.Empty;
				bool flag;
				if (this.isReplace)
				{
					flag = this.search.Replace(this.searchText, this.replaceText, (this.searchOptions | SearchOptions.BackwardSearch) & ~SearchOptions.CycledSearch, this.searchExpression);
				}
				else
				{
					flag = this.search.Find(text, (this.searchOptions | SearchOptions.BackwardSearch) & ~SearchOptions.CycledSearch, this.searchExpression, this.FirstSearch, false);
				}
				bool flag2 = !flag;
				CodeEditor search = this.curSearch;
				if (search == null)
				{
					search = this.search;
				}
				if (!flag && this.search != this.cycledSearch)
				{
					while (!flag)
					{
						CodeEditor search2 = this.search;
						if (!this.NextSearch(this.searchOptions, ref sourceFileNameFromSearch, ref search2))
						{
							break;
						}
						if (search2 != null)
						{
							if (search2 == search)
							{
								flag = search2.CycledSearch(text, this.searchOptions | SearchOptions.BackwardSearch | SearchOptions.CycledSearch, this.searchExpression, false);
								if (flag)
								{
									this.cycledSearch = ((search != null) ? search : search2);
								}
								break;
							}
							flag = search2.Find(text, ((this.searchOptions | SearchOptions.BackwardSearch) & ~SearchOptions.CycledSearch) | SearchOptions.EntireScope, this.searchExpression, true, false);
						}
						else
						{
							if (!string.IsNullOrEmpty(text2) && string.Compare(text2, sourceFileNameFromSearch) == 0)
							{
								break;
							}
							flag = this.FindText(sourceFileNameFromSearch, text, (this.searchOptions & ~SearchOptions.BackwardSearch & ~SearchOptions.CycledSearch) | SearchOptions.EntireScope, this.searchExpression, out search2);
						}
						if (text2 == string.Empty)
						{
							text2 = sourceFileNameFromSearch;
						}
					}
				}
				if (flag && this.isReplace && flag2)
				{
					this.ReplaceCurrent(this.replaceText, (this.searchOptions | SearchOptions.BackwardSearch) & ~SearchOptions.CycledSearch, null);
				}
				result = flag;
			}
			else
			{
				result = false;
			}
			return result;
		}
		protected virtual bool FindNext(string text)
		{
			bool result;
			if (this.CanFindNext())
			{
				if (text == null)
				{
					text = this.searchText;
				}
				if (this.searchExpression != null && (this.searchExpression.Options & RegexOptions.RightToLeft) != RegexOptions.None)
				{
					this.searchExpression = new Regex(this.searchExpression.ToString(), this.searchExpression.Options & ~RegexOptions.RightToLeft);
				}
				string sourceFileNameFromSearch = this.GetSourceFileNameFromSearch(this.search);
				string text2 = string.Empty;
				bool flag;
				if (this.isReplace)
				{
					flag = this.search.Replace(this.searchText, this.replaceText, this.searchOptions & ~SearchOptions.BackwardSearch & ~SearchOptions.CycledSearch, this.searchExpression);
				}
				else
				{
					flag = this.search.Find(text, this.searchOptions & ~SearchOptions.BackwardSearch & ~SearchOptions.CycledSearch, this.searchExpression, this.FirstSearch, false);
				}
				bool flag2 = !flag;
				CodeEditor search = this.curSearch;
				if (search == null)
				{
					search = this.search;
				}
				if (!flag && this.search != this.cycledSearch)
				{
					while (!flag)
					{
						CodeEditor search2 = this.search;
						if (!this.NextSearch(this.searchOptions, ref sourceFileNameFromSearch, ref search2))
						{
							break;
						}
						if (search2 != null)
						{
							if (search2 == search)
							{
								flag = search2.CycledSearch(text, (this.searchOptions & ~SearchOptions.BackwardSearch) | SearchOptions.CycledSearch, this.searchExpression, false);
								if (flag)
								{
									this.cycledSearch = ((search != null) ? search : search2);
									this.firstSearch = false;
								}
								break;
							}
							flag = search2.Find(text, (this.searchOptions & ~SearchOptions.BackwardSearch & ~SearchOptions.CycledSearch) | SearchOptions.EntireScope, this.searchExpression, true, false);
						}
						else
						{
							if (!string.IsNullOrEmpty(text2) && string.Compare(text2, sourceFileNameFromSearch) == 0)
							{
								break;
							}
							flag = this.FindText(sourceFileNameFromSearch, text, (this.searchOptions & ~SearchOptions.BackwardSearch & ~SearchOptions.CycledSearch) | SearchOptions.EntireScope, this.searchExpression, out search2);
						}
						if (text2 == string.Empty)
						{
							text2 = sourceFileNameFromSearch;
						}
					}
				}
				if (flag && this.isReplace && flag2)
				{
					this.ReplaceCurrent(this.replaceText, this.searchOptions & ~SearchOptions.BackwardSearch & ~SearchOptions.CycledSearch, null);
				}
				result = flag;
			}
			else
			{
				result = false;
			}
			return result;
		}
		public virtual void UpdateSearch(CodeEditor search, bool update)
		{
			this.search = search;
			if (update && this.updateCount == 0)
			{
				this.curSearch = search;
				this.cycledSearch = null;
			}
		}
		public virtual void Done(CodeEditor search)
		{
			Circus.CodeEditor.Dialogs.SearchDialog.Done(search);
			if (this.search == search)
			{
				this.search = null;
				this.FirstSearch = true;
			}
			if (this.cycledSearch == search)
			{
				this.cycledSearch = null;
			}
			if (this.curSearch == search)
			{
				this.curSearch = null;
			}
		}
		public virtual void Init(ref CodeEditor search, SearchOptions options)
		{
			this.InitSearchList(ref search, options);
			this.search = search;
			this.curSearch = search;
		}
		public virtual void OnBeforeSearch(ref CodeEditor search, SearchOptions options, string text)
		{
		}
		public virtual bool FindText(string fileName, string text, SearchOptions options, Regex expression, out CodeEditor search)
		{
			return this.FindText(fileName, text, options, expression, out search, Point.Empty);
		}
		public virtual bool FindText(string fileName, string text, SearchOptions options, Regex expression, out CodeEditor search, Point position)
		{
			search = null;
			bool result;
			if (!new FileInfo(fileName).Exists)
			{
				result = false;
			}
			else
			{
				TextStrings textStrings = new TextStrings();
                //textStrings.LoadFile(fileName);
				result = this.FindText(fileName, textStrings, text, options, expression, out search);
			}
			return result;
		}
		protected virtual bool FindText(string fileName, TextStrings strings, string text, SearchOptions options, Regex expression, out CodeEditor search)
		{
			return this.FindText(fileName, strings, text, options, expression, out search, Point.Empty);
		}
		protected virtual bool FindText(string fileName, TextStrings strings, string text, SearchOptions options, Regex expression, out CodeEditor search, Point position)
		{
			bool flag = false;
			search = null;
			int len;
			Match match;
			flag = strings.Find(text, options, expression, ref position, out len, out match);
			if (flag)
			{
				this.updateCount++;
				try
				{
					this.OnTextFound(fileName, text, options, expression, match, position, len, expression != null && (expression.Options & RegexOptions.Multiline) != RegexOptions.None, out search);
					this.FirstSearch = false;
				}
				finally
				{
					this.updateCount--;
				}
			}
			return flag;
		}
		public virtual bool Find(CodeEditor search, string text, SearchOptions options, Regex expression)
		{
			return this.FindOrReplace(search, text, string.Empty, options, expression);
		}
		public virtual bool FindOrReplace(CodeEditor search, string text, string replaceWith, SearchOptions options, Regex expression)
		{
			this.firstSearch = true;
			this.Init(ref search, options);
			this.searchOptions = options;
			this.searchExpression = expression;
			this.searchText = text;
			this.replaceText = replaceWith;
			string sourceFileNameFromSearch = this.GetSourceFileNameFromSearch(search);
			string text2 = string.Empty;
			bool flag = search != null && search.Find(text, options & ~SearchOptions.CycledSearch, expression);
			CodeEditor search2 = this.curSearch;
			if (search2 == null)
			{
				search2 = search;
			}
			if (!flag && (search == null || search != this.cycledSearch))
			{
				while (!flag)
				{
					CodeEditor search3 = search;
					if (!this.NextSearch(this.searchOptions, ref sourceFileNameFromSearch, ref search3))
					{
						break;
					}
					if (search3 != null)
					{
						if (search2 == null)
						{
							search2 = search3;
						}
						if (search3 == search2)
						{
							flag = search3.CycledSearch(text, options | SearchOptions.CycledSearch, expression, false);
							if (flag)
							{
								this.cycledSearch = ((search2 != null) ? search2 : search3);
							}
							break;
						}
						flag = search3.Find(text, (options & ~SearchOptions.CycledSearch) | SearchOptions.EntireScope, expression, true, false);
					}
					else
					{
						if (!string.IsNullOrEmpty(text2) && string.Compare(text2, sourceFileNameFromSearch) == 0)
						{
							break;
						}
						flag = this.FindText(sourceFileNameFromSearch, text, (options & ~SearchOptions.BackwardSearch & ~SearchOptions.CycledSearch) | SearchOptions.EntireScope, this.searchExpression, out search3);
					}
					if (text2 == string.Empty)
					{
						text2 = sourceFileNameFromSearch;
					}
				}
			}
			return flag;
		}
		public bool Find(string s, SearchOptions options, Regex expression, ref Point position, out int len, out Match match)
		{
			this.Init(ref this.search, SearchOptions.None);
			len = 0;
			match = Match.Empty;
			return this.search != null && this.search.Find(s, options, expression, ref position, out len, out match);
		}
		public virtual bool FindPrevious()
		{
			return this.FindPrevious(null);
		}
		public virtual bool FindNext()
		{
			return this.FindNext(null);
		}
		public virtual bool CanFindPrevious()
		{
			return !this.firstSearch && this.search != null;
		}
		public virtual bool CanFindNext()
		{
			return !this.firstSearch && this.search != null;
		}
		public virtual bool CanFindNextSelected()
		{
			return this.search is CodeEditor && this.search.CanFindNextSelected();
		}
		public virtual bool CanFindPreviousSelected()
		{
			return this.search is CodeEditor && this.search.CanFindPreviousSelected();
		}
		public virtual bool FindNextSelected()
		{
			return this.CanFindNextSelected() && this.FindNext(((CodeEditor)this.search).Selection.SelectedText);
		}
		public virtual bool FindPreviousSelected()
		{
			return this.CanFindPreviousSelected() && this.FindPrevious(((CodeEditor)this.search).Selection.SelectedText);
		}
		public virtual bool ReplaceAll(CodeEditor search, string text, string replaceWith, SearchOptions options, Regex expression, out int count, out bool abort)
		{
			abort = false;
			this.Init(ref search, options);
			this.firstSearch = true;
			this.searchOptions = options;
			this.searchExpression = expression;
			this.searchText = text;
			this.replaceText = replaceWith;
			count = 0;
			int num = 0;
			string sourceFileNameFromSearch = this.GetSourceFileNameFromSearch(search);
			if (search != null)
			{
				search.ReplaceAll(text, replaceWith, (options | SearchOptions.EntireScope) & ~SearchOptions.CycledSearch & ~SearchOptions.PromptOnReplace, expression, out num, out abort);
				count += num;
			}
			CodeEditor search2 = this.curSearch;
			if (search2 == null)
			{
				search2 = search;
			}
			CodeEditor search3 = search;
			while (this.NextSearch(this.searchOptions, ref sourceFileNameFromSearch, ref search3))
			{
				if (search3 != null)
				{
					if (search2 == null)
					{
						search2 = search3;
					}
					if (search3 == search2)
					{
						break;
					}
					num = 0;
					search3.ReplaceAll(text, replaceWith, (options | SearchOptions.EntireScope) & ~SearchOptions.CycledSearch & ~SearchOptions.PromptOnReplace, expression, out num, out abort);
					count += num;
				}
				else
				{
					if (this.FindText(sourceFileNameFromSearch, text, (this.searchOptions & ~SearchOptions.BackwardSearch & ~SearchOptions.CycledSearch) | SearchOptions.EntireScope, this.searchExpression, out search3))
					{
						if (search3 != null)
						{
							num = 0;
							search3.ReplaceAll(text, replaceWith, (options | SearchOptions.EntireScope) & ~SearchOptions.CycledSearch & ~SearchOptions.PromptOnReplace, expression, out num, out abort);
							count += num;
						}
					}
				}
			}
			return count > 0;
		}
		public virtual int MarkAll(CodeEditor search, string text, SearchOptions options, Regex expression, bool clearPrevious)
		{
			this.Init(ref search, options);
			this.firstSearch = true;
			this.searchOptions = options;
			this.searchExpression = expression;
			this.searchText = text;
			int num = 0;
			string sourceFileNameFromSearch = this.GetSourceFileNameFromSearch(search);
			if (search != null)
			{
				num += search.MarkAll(text, (options | SearchOptions.EntireScope) & ~SearchOptions.CycledSearch, expression, clearPrevious);
			}
			CodeEditor search2 = this.curSearch;
			if (search2 == null)
			{
				search2 = search;
			}
			CodeEditor search3 = search;
			while (this.NextSearch(this.searchOptions, ref sourceFileNameFromSearch, ref search3))
			{
				if (search3 != null)
				{
					if (search2 == null)
					{
						search2 = search3;
					}
					if (search3 == search2)
					{
						break;
					}
					num += search3.MarkAll(text, (options | SearchOptions.EntireScope) & ~SearchOptions.CycledSearch, expression, clearPrevious);
				}
				else
				{
					if (this.FindText(sourceFileNameFromSearch, text, (this.searchOptions & ~SearchOptions.BackwardSearch & ~SearchOptions.CycledSearch) | SearchOptions.EntireScope, this.searchExpression, out search3))
					{
						if (search3 != null)
						{
							num += search3.MarkAll(text, (options | SearchOptions.EntireScope) & ~SearchOptions.CycledSearch, expression, clearPrevious);
						}
					}
				}
			}
			return num;
		}
		public virtual void OnTextFound(string fileName, string text, SearchOptions options, Regex expression, Match match, Point position, int len, bool multiLine, out CodeEditor search)
		{
			search = null;
			if (this.TextFound != null)
			{
				TextFoundEventArgs textFoundEventArgs = new TextFoundEventArgs(fileName, text, options, expression, match, position, len, multiLine);
				this.TextFound(this, textFoundEventArgs);
				search = textFoundEventArgs.Search;
			}
		}
		public virtual void OnTextFound(CodeEditor search)
		{
			this.search = search;
			if (this.TextFound != null)
			{
				this.TextFound(this, new TextFoundEventArgs(search));
			}
		}
		public virtual void ShowNotFound(CodeEditor search, string caption)
		{
			if (this.cycledSearch == search)
			{
				this.cycledSearch = null;
			}
			if ((this.searchOptions & SearchOptions.SilentSearch) == SearchOptions.None)
			{
				MessageBox.Show(string.Format(((this.searchOptions & SearchOptions.CycledSearch) != SearchOptions.None && !this.FirstSearch) ? StringConsts.SearchReachedStartPos : StringConsts.StringNotFound, this.searchText), caption);
			}
		}
		public bool Find(string text, SearchOptions options, Regex expression, IList<Range> ranges)
		{
			this.Init(ref this.search, options);
			return this.search != null && this.search.Find(text, options, expression, ranges);
		}
		public bool Replace(string text, string replaceWith)
		{
			this.Init(ref this.search, SearchOptions.None);
			return this.search != null && this.search.Replace(text, replaceWith);
		}
		public bool Replace(string text, string replaceWith, SearchOptions options)
		{
			this.Init(ref this.search, options);
			return this.search != null && this.search.Replace(text, replaceWith, options);
		}
		public bool Replace(string text, string replaceWith, SearchOptions options, Regex expression)
		{
			this.Init(ref this.search, options);
			return this.search != null && this.search.Replace(text, replaceWith, options, expression);
		}
		public bool NeedReplaceCurrent(out Match match)
		{
			match = Match.Empty;
			this.Init(ref this.search, SearchOptions.None);
			return this.search != null && this.search.NeedReplaceCurrent(out match);
		}
		public bool ReplaceCurrent(string replaceWith, SearchOptions options, Match match)
		{
			this.Init(ref this.search, options);
			return this.search != null && this.search.ReplaceCurrent(replaceWith, options, match);
		}
		public void StartIncrementalSearch()
		{
			this.Init(ref this.search, SearchOptions.None);
			if (this.search != null)
			{
				this.search.StartIncrementalSearch();
			}
		}
		public void StartIncrementalSearch(bool backwardSearch)
		{
			this.Init(ref this.search, SearchOptions.None);
			if (this.search != null)
			{
				this.search.StartIncrementalSearch(backwardSearch);
			}
		}
		public void FinishIncrementalSearch()
		{
			this.Init(ref this.search, SearchOptions.None);
			if (this.search != null)
			{
				this.search.FinishIncrementalSearch();
			}
		}
		public bool IncrementalSearch(string key, bool deleteLast)
		{
			this.Init(ref this.search, SearchOptions.None);
			return this.search != null && this.search.IncrementalSearch(key, deleteLast);
		}
		public string GetTextToSearchAtCursor()
		{
			this.Init(ref this.search, SearchOptions.None);
			return (this.search != null) ? this.search.GetTextToSearchAtCursor() : string.Empty;
		}
		public bool CanSearchSelection(out string selectedText)
		{
			selectedText = string.Empty;
			this.Init(ref this.search, SearchOptions.None);
			return this.search != null && this.search.CanSearchSelection(out selectedText);
		}
		public bool DoFind(string str, SearchOptions options, Regex expression, bool firstSearch, bool silent)
		{
			this.Init(ref this.search, options);
			return this.search != null && this.search.Find(str, options, expression, this.FirstSearch, silent);
		}
		public bool SearchCycled(string str, SearchOptions options, Regex expression, bool silent)
		{
			this.Init(ref this.search, options);
			return this.search != null && this.search.CycledSearch(str, options, expression, silent);
		}
	}
}
